package io;

import org.springframework.core.io.FileSystemResourceLoader;
import org.springframework.core.io.Resource;

/**
 *   + org.springframework.core.io.ResourceLoader
 *     + org.springframework.core.io.DefaultResourceLoader
 *       + org.springframework.core.io.FileSystemResourceLoader
 *       + org.springframework.core.io.ClassRelativeResourceLoader
 *       + **org.springframework.context.support.AbstractApplicationContext**
 *       + 完全限定的URL:file:C:\\test.log
* + 类路径伪URL:classpath:test.log
* + 相对路径:WEB-INF/test.log
* **获取到资源加载器后需要调用exists来检查是否存在。**
 */
public class ResourceLoaderDemo {

    public static void main(String[] args) {
        fsLoaderDemo();
    }

    public static void fsLoaderDemo(){
        String file = System.getProperty("user.dir")+"\\think-in-spring\\spring-resource\\src\\main\\java\\io\\SpringResourceDemo.java";
        System.out.println(file);
        FileSystemResourceLoader fsload = new FileSystemResourceLoader();
        Resource resource = fsload.getResource(file);
        System.out.println(resource.getClass()+"|"+resource.exists());
        file = System.getProperty("user.dir")+"\\think-in-spring\\spring-resource\\src\\main\\java\\io\\SpringResourceDemo.java111";
        resource = fsload.getResource(file);
        System.out.println(resource.getClass()+"|"+resource.exists());
    }
}
